package com.bawei.music.contentprovider;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.bawei.music.MainActivity;
import com.bawei.music.R;

import java.util.List;

public class ContentProviderActivity3 extends AppCompatActivity implements View.OnClickListener {
    private Button btGetSong;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_content_provider3);
        //安卓6.0动态获取权限
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            requestPermissions(new String[]{
                    Manifest.permission.WRITE_EXTERNAL_STORAGE,
                    Manifest.permission.READ_EXTERNAL_STORAGE,
                    Manifest.permission.READ_CONTACTS,
                    Manifest.permission.WRITE_CONTACTS,
                    Manifest.permission.READ_SMS,
                    Manifest.permission.CALL_PHONE,
                    Manifest.permission.ACCESS_NETWORK_STATE,
                    Manifest.permission.READ_PHONE_STATE,
                    Manifest.permission.WRITE_CALL_LOG,
                    Manifest.permission.READ_CALL_LOG
            },101);
        }

        btGetSong = (Button) findViewById(R.id.bt_getSong);
        btGetSong.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        List<Song> songs = SongUtils.getSongs(this);
        Log.d("ytx", "本地音乐数据: "+songs);
    }
}